package com.datang.litejvm.engin;

import com.datang.litejvm.loader.ClassLoader;
import java.io.FileNotFoundException;
import java.io.IOException;

/**
 * @author: 顶风少年
 * @Description: jvm
 * @date: 10:50 2022/6/16
 **/
public class MiniJVM {
	
	public void run(String[]classPaths , String className) throws FileNotFoundException, IOException{
		ClassLoader loader = new ClassLoader();
		for(int i=0;i<classPaths.length ; i++){
			loader.addClassPath(classPaths[i]);
		}
		
		MethodArea methodArea= MethodArea.getInstance();
		
		methodArea.setClassFileLoader(loader);
		
		ExecutorEngine engine = new ExecutorEngine();

		className = className.replace(".", "/");

		engine.execute(methodArea.getMainMethod(className));
	}
	
}
